package com.atguigu.lease.common.springmvc;

import com.atguigu.lease.common.exceptions.LeaseException;
import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExceptionHandlers {


    @ExceptionHandler(LeaseException.class)
    public Result leaseException(LeaseException e) {
        e.printStackTrace();
        return Result.fail(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result exceptionHan(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
